<?php

class PlanningModel {

	private $agenda;

	public function __construct () {
	}

	public function showPlanning(){
		//region Instanciation de la classe Agenda
		require_once ('Agenda.class.php');
		$this->agenda = new Agenda();
		$this->agenda->set_interval(date('Y-m'), (date('Y')+1).'-'.date('m'));
		//endregion
		self::generateEventOnPlanning();
		if(DEBUG) echo '<pre>'.print_r($this->agenda, true).'</pre>';
		return $this->agenda->create();
	}

	private function generateEventOnPlanning(){
		require_once('Planning.php');
		$planning = new Planning();
		$data = $planning->showAll();
		foreach($data as $key => $val)
		    $this->agenda->add_periode(array($array['date_debut'], $array['date_fin']), $array['titre'], array('style'=>'background:#C79810;', 'onClick'=>"showErreur();"));
	}


}